﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Dapper.Library
{
    /// <summary>
    /// SQL语句帮助操作
    /// </summary>
    public static class SqlExtension
    {
        /// <summary>
        ///转StartsWith
        /// </summary>
        /// <returns></returns>
        public static string ToStartsWith(this string keyWords)
        {

            string sqlLike = string.Empty;

            if (!string.IsNullOrEmpty(keyWords))
            {
                sqlLike = keyWords + '%';
            }
            return sqlLike;
        }

        /// <summary>
        ///转EndsWith
        /// </summary>
        /// <returns></returns>
        public static string ToEndsWith(this string keyWords)
        {
            string sqlLike = string.Empty;
            if (!string.IsNullOrEmpty(keyWords))
            {
                sqlLike = '%' + keyWords;
            }
            return sqlLike;
        }

        /// <summary>
        ///转Contains
        /// </summary>
        /// <returns></returns>
        public static string ToContains(this string keyWords)
        {

            string sqlLike = string.Empty;

            if (!string.IsNullOrEmpty(keyWords))
            {
                sqlLike = '%' + keyWords + '%';
            }
            return sqlLike;
        }
    }
}
